
$(document).ready(function(){
//	$(".listItems div a").hover(function(){
//		$(this).children("strong").stop(true).animate({
//			height: "30px"
//		});
//	},function(){
//		$(this).children("strong").stop(true).animate({
//			height:"0px"
//		});
//	});
	$("#getBoxComment").click(function(e){
		$("#boxComment").stop(true).slideToggle("fast");
		e.stopPropagation();
		return false;
	});
	$("#boxComment").click(function(e){
		e.stopPropagation();
		return false;
	});
	$("body").click(function(){
		if($("#boxComment").is(":visible")){
			$("#getBoxComment").trigger("click");
		}
	});
	$("img").lazyload({
	     effect : "fadeIn"
	 });
	//lay ten domain
	var domain = window.location.protocol + "//" + window.location.host; 
	//lay the loai search
	$('.tabTypeSearch a').click(function(){
		var type = $(this).attr('id');
		$('#typeSearch').attr('value',type);
	});
	/** Auto complete*/
   $("#kwSearch").autocomplete({
       source: function (request, response) {
           $.ajax({
               url: $("#searchUrl").val(),
               data: {
            	   kwSearch: request.term,
               },
               dataType: "json",
               success: function(data) {
                   response($.map(data, function(el, index) {
                       return {
                       	   idComic: el['idComic'],
                           nameComic: el['nameComic'],
                           nameUnsigned: el['nameUnsignedComic'],
                           image: el['linkImage'] +"/s120-c/"+el['nameImage'],
                           idLoaiAnh: el['idLoaiAnh'],
                           aliasLoaiAnh: el['aliasLoaiAnh'],
                       };
                   }));
               }
           });
       }
   }).data("autocomplete")._renderItem = function (ul, item) {
       return $("<li />")
           .data("item.autocomplete", item)
           .append("<a target='_blank' href='"+domain+"/anh-dep/"+item.aliasLoaiAnh+"/"+item.nameUnsigned+"-L"+item.idLoaiAnh+"-A"+item.idComic+".htm' title='Ảnh "+ item.nameComic +"'><img src='" + item.image + "' alt='"+item.nameComic+"'/>" + item.nameComic + "</a>")
           .appendTo(ul);
   };
   $("ul.ui-autocomplete,ul.ui-autocomplete li,ul.ui-autocomplete li a").live("click",function(e){
   	e.stopPropagation();
   	$("ul.ui-autocomplete").addClass("disable");
   });
   $("ul.ui-autocomplete li a").live("click",function(e){
   	var u = this.href;
   	location.href = u;
   });
   $("body").click(function(){
   	$("ul.ui-autocomplete").removeClass("disable").hide();
   });
});
